#include"Grid.h"
#define NUMTEST 200000

void  FindWinnerTest();
void  InsertCoinTest();
void  ExtractCoinTest();

int main (void)
{
	//InsertCoinTest();
	//FindWinnerTest();
	ExtractCoinTest();
}
void ExtractCoinTest()
{
Grid grid;
	grid.Reset();
	grid.InsertCoin(YELLOW,0);		
	grid.Trace();
	grid.InsertCoin(RED,1);		
	grid.Trace();
	grid.InsertCoin(RED,1);		
	grid.Trace();
	grid.InsertCoin(YELLOW,1);	
	grid.Trace();
	grid.InsertCoin(YELLOW,1);	
	grid.Trace();
	grid.InsertCoin(YELLOW,1);	
	grid.Trace();
	grid.InsertCoin(YELLOW,1);	
	grid.Trace();
	grid.InsertCoin(YELLOW,1);	
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
	grid.ExtractCoin(1);
	grid.Trace();
}

void InsertCoinTest()
{

Grid grid;
	// 0 0 0 0 0 0 0
	// 0 0 0 0 1 0 0
	// 0 0 2 1 2 0 0
	// 0 2 1 2 1 1 0
	// 0 1 1 2 2 2 1
	// 2 1 1 2 2 1 1
	for(long i = 0;i < NUMTEST;++i)
	{
	
	
	grid.Reset();
	grid.InsertCoin(YELLOW,0);		
	grid.InsertCoin(RED,1);		
	grid.InsertCoin(RED,1);		
	grid.InsertCoin(YELLOW,1);		
	
	grid.InsertCoin(RED,2);		
	grid.InsertCoin(RED,2);			
	grid.InsertCoin(RED,2);			
	grid.InsertCoin(YELLOW,2);		
	
	grid.InsertCoin(YELLOW,3);		
	grid.InsertCoin(YELLOW,3);		
	grid.InsertCoin(YELLOW,3);		
	grid.InsertCoin(RED,3);		
	
	grid.InsertCoin(RED,5);			
	grid.InsertCoin(YELLOW,5);		
	grid.InsertCoin(RED,5);
				
	grid.InsertCoin(YELLOW,4);		
	grid.InsertCoin(YELLOW,4);		
	grid.InsertCoin(RED,4);
	grid.InsertCoin(YELLOW,4);		
	grid.InsertCoin(RED,4);
	
	//grid.InsertCoin(RED,6);			
	//grid.InsertCoin(RED,6);			
	}
}

void FindWinnerTest()
{
	Grid grid;
	// 0 0 0 0 0 0 0
	// 0 0 0 0 1 0 0
	// 0 0 2 1 2 0 0
	// 0 2 1 2 1 1 0
	// 0 1 1 2 2 2 0
	// 2 1 1 2 2 1 0
	grid.Reset();
	grid.InsertCoin(YELLOW,0);		
	grid.InsertCoin(RED,1);		
	grid.InsertCoin(RED,1);		
	grid.InsertCoin(YELLOW,1);		
	
	grid.InsertCoin(RED,2);		
	grid.InsertCoin(RED,2);			
	grid.InsertCoin(RED,2);			
	grid.InsertCoin(YELLOW,2);		
	
	grid.InsertCoin(YELLOW,3);		
	grid.InsertCoin(YELLOW,3);		
	grid.InsertCoin(YELLOW,3);		
	grid.InsertCoin(RED,3);		
	
	grid.InsertCoin(RED,5);			
	grid.InsertCoin(YELLOW,5);		
	grid.InsertCoin(RED,5);
				
	grid.InsertCoin(YELLOW,4);		
	grid.InsertCoin(YELLOW,4);		
	grid.InsertCoin(RED,4);
	grid.InsertCoin(YELLOW,4);		
	grid.InsertCoin(RED,4);
		
	for(long i = 0;i < NUMTEST;++i)
	{
		Point p = grid.FindWinner();
	}
}